﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;

namespace org.xisoft.game.utils.game
{
    public class ChessItem: ICloneable
    {
        public Boolean IsBlack { get; set; }
        public byte Index { get; set; }

        public virtual String DisplayName { get { return Index + "";  } }

        /// <summary>
        /// 棋盘中的位置
        /// </summary>
        public int PositionX
        {
            get;
            set;
        }


        public int PositionY
        {

            get;
            set;
        }


        public object Clone()
        {
            MemberInfo[] members = FormatterServices.GetSerializableMembers(GetType());
            Object[] values = FormatterServices.GetObjectData(this, members);
            Object obj = FormatterServices.GetUninitializedObject(GetType());
            return FormatterServices.PopulateObjectMembers(obj, members, values);
        }

        public virtual int Score { get; set; }


        public override string ToString()
        {
            return "{X:"+ PositionX + ",Y:"+PositionY + (IsBlack?",color:black":",color:red")+ ",score:"+ Score+"}";
        }
    }
}
